package com.gxa.service.impl;

import com.gxa.domain.entity.ProductInfo;
import com.gxa.mapper.ProductInfoMapper;
import com.gxa.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductInfoServiceImpl implements ProductInfoService {
    @Autowired
    private ProductInfoMapper productInfoMapper;

    @Override
    public ProductInfo getByBarcodeNo(String barcodeNo) {
        System.out.println("查询参数 barcodeNo: " + barcodeNo);
        ProductInfo product = productInfoMapper.selectByBarcodeNo(barcodeNo);
        System.out.println("查到的商品对象: " + product);
        return product;
    }

    @Override
    public void updateStock(String barcodeNo, Integer quantity) {
        productInfoMapper.updateStockByBarcodeNo(barcodeNo, quantity);
    }
    @Override
    public List<ProductInfo> list() {
        return productInfoMapper.selectAll();
    }
} 